package com.foreveross.fetl.util;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.text.NumberFormat;

public class StringUtils {
	
	/**
	 * 取得错误堆栈信息
	 * @param t
	 * @return
	 */
	public static String getStackTrace(Throwable t) {
		StringWriter sw = new StringWriter();
		PrintWriter pw = new PrintWriter(sw, true);
		t.printStackTrace(pw);
		pw.flush();
		sw.flush();
		return sw.toString();
	}
	public static Double getDouble(double d){
		NumberFormat nf = NumberFormat.getNumberInstance();
	    nf.setMaximumFractionDigits(2);
	    return Double.valueOf(nf.format(d));
	}
	
}
